package yoyo.secret.app;

import yoyo.secret.app.base.YoyoApplication;
import yoyo.secret.app.db.DataBaseOperation;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class LoadingActivity extends Activity {

	private String[] defulat = { "游戏", "网站", "腾讯" };

	private DataBaseOperation mDataBaseOperation;

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.loading);

		mDataBaseOperation = ((YoyoApplication) getApplication()).dataBaseOperation;

		ImageView logoView = (ImageView) findViewById(R.id.logo);
		Animation animation = AnimationUtils.loadAnimation(this, R.anim.loading_anim);
		logoView.startAnimation(animation);

		for (int i = 0; i < defulat.length; i++) {
			mDataBaseOperation.addClassification(defulat[i]);
		}

		new Handler().postDelayed(new Runnable() {

			@Override
			public void run() {
				// TODO Auto-generated method stub
				Intent intent = new Intent(LoadingActivity.this, YoyoActivity.class);
				startActivity(intent);
				overridePendingTransition(R.anim.scale_activity, R.anim.scale_activity);
				LoadingActivity.this.finish();
			}
		}, 2800);

		animation.setAnimationListener(new AnimationListener() {

			@Override
			public void onAnimationStart(Animation animation) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onAnimationRepeat(Animation animation) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onAnimationEnd(Animation animation) {

			}
		});
	}
}
